﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StoreHouseA
{
    using StoreHouseDataSetTableAdapters;

    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            insert_out();

            this.Close();
        }

        private void insert_out()
        {
            string in_customer = comboBox1.Text;
            string in_code = comboBox2.Text;
            string in_level = comboBox4.Text;
            string in_location = textBox2.Text;
            string in_agent = comboBox3.Text;
            string in_car = textBox4.Text;
            string in_memo = textBox5.Text;
            
            decimal in_weight = numericUpDown1.Value;
            decimal in_hang = numericUpDown2.Value;

            DateTime in_date = dateTimePicker1.Value.Date;
            string in_oman = Program.oman;
            DateTime in_otime = DateTime.Now;

            tb_inoutTableAdapter a = new tb_inoutTableAdapter();
            a.Insert(in_code, in_level, in_customer, in_location, 0, in_weight,
                in_date, in_agent, in_car, "", "", "", in_memo, in_oman, in_otime);
            QueriesTableAdapter q = new QueriesTableAdapter();
            q.submit_deal(in_code, in_customer, in_date);
        }

        private void button1_Click(object sender, EventArgs e)
        {
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
        }

        private void textBox3_Click(object sender, EventArgs e)
        {
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                listView1.Items.Remove(listView1.SelectedItems[0]);
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == (new Form40()).ShowDialog())
            {
                listView1.Items.Add(new ListViewItem(new string[] {
                    Form40.bag_code, Form40.bag_weight
                }));
            }
        }
    }
}
